#!/usr/bin/python3
# coding=utf-8

class UnifyBook:

    def __init__(self) -> None:
        super().__init__()
        self.id = None
        self.title = None
        self.cover = None
        self.authorId = None
        self.author = None
        self.status = None
        self.categoryId = None
        self.categoryName = None
        self.latestChapter = None
        self.description = None
        self.words = None
        self.gmtCreate = None
        self.gmtModified = None
        self.refUrl = None
        self.bookUpdateTime = None

    def getId(self):
        return self.id

    def setId(self, id):
        self.id = id


    def getTitle(self):
        return self.title

    def setTitle(self, title):
        self.title = title

    def getCover(self):
        return self.cover

    def setCover(self, cover):
        self.cover = cover

    def getAuthorId(self):
        return self.authorId

    def setAuthorId(self, authorId):
        self.authorId = authorId

    def getAuthor(self):
        return self.author

    def setAuthor(self, author):
        self.author = author

    def getStatus(self):
        return self.status

    def setStatus(self, status):
        self.status = status

    def getCategoryId(self):
        return self.categoryId

    def setCategoryId(self, categoryId):
        self.categoryId = categoryId

    def getCategoryName(self):
        return self.categoryName

    def setCategoryName(self, categoryName):
        self.categoryName = categoryName

    def getLatestChapter(self):
        return self.latestChapter

    def setLatestChapter(self, latestChapter):
        self.latestChapter = latestChapter

    def getDescription(self):
        return self.description

    def setDescription(self, description):
        self.description = description

    def getWords(self):
        return self.words

    def setWords(self, words):
        self.words = words

    def getGmtCreate(self):
        return self.gmtCreate

    def setGmtCreate(self, gmtCreate):
        self.gmtCreate = gmtCreate

    def getGmtModified(self):
        return self.gmtModified

    def setGmtModified(self, gmtModified):
        self.gmtModified = gmtModified

    def getRefUrl(self):
        return self.refUrl

    def setRefUrl(self, refUrl):
        self.refUrl = refUrl

    def getBookUpdateTime(self):
        return self.bookUpdateTime

    def setBookUpdateTime(self, bookUpdateTime):
        self.bookUpdateTime = bookUpdateTime

    def getSaveSql(self):
        try:
            # return "11111111"
            saveSql = "INSERT INTO unify_book(title, cover, author, status, category_name, " \
                      "latest_chapter, description, words, gmt_create, book_update_time, ref_url) " \
                      "VALUES ('%s','%s','%s','%s','%s'," \
                      "'%s','%s','%s','%s','%s','%s')" % \
                (self.title, self.cover, self.author, self.status, self.categoryName,
                 self.latestChapter, self.description, self.words, self.gmtCreate, self.bookUpdateTime, self.refUrl)
            return saveSql
        except BaseException as e:
            print(e)
            return

    def getInfoByTitleSql(self, title):
        querySql = "SELECT id from unify_book where title = '%s'" % title
        return querySql